import { TShopTips } from "../../../Message/Db/Tables/TShopTips";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class ShopTipsConfig
    
    export  class ShopTipsConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._panicBuyList = [];
            if (ShopTipsConfig._instance != null) 
            {
                throw new Error(" ShopTipsConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TShopTips();
                loc1.id = loc2.id;
                loc1.type = loc2.type;
                loc1.tips = StringHelper.getString(loc2.tips);
                this._map[loc1.id] = loc1;
                if (loc1.type == 1) 
                {
                    this._panicBuyList.push(loc1);
                }
                if (!(loc1.id > this._maxIndex)) 
                {
                    continue;
                }
                this._maxIndex = loc1.id;
            }
            this._panicLength = this._panicBuyList.length;
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_shop_tips.json");
            this.write(loc1);
            return;
        }

        public getTipsById(arg1: int): string
        {
            var loc1="";
            var loc2=this._map[arg1] as TShopTips;
            if (loc2) 
            {
                loc1 = loc2.tips;
            }
            return loc1;
        }

        public ShopTipsConfig.get maxIndex(): int
        {
            return this._maxIndex;
        }

        public ShopTipsConfig.get panicLength(): int
        {
            return this._panicLength;
        }

        public getPanicTipsByIndex(arg1: int): string
        {
            return (this._panicBuyList[arg1] as TShopTips).tips;
        }

        public static get instance(): ShopTipsConfig
        {
            if (ShopTipsConfig._instance == null) 
            {
                ShopTipsConfig._instance = new ShopTipsConfig();
            }
            return ShopTipsConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_panicBuyList: Array<any>;

        /* internal */ /* var */_maxIndex: int;

        /* internal */ /* var */_panicLength: int;

        /* internal */ static /* var */_instance: ShopTipsConfig;
    }
